//
//  ScenicSpotsButton.m
//  WXTourism
//
//  Created by 南京斯布乔 on 16/8/11.
//  Copyright © 2016年 南京斯布乔. All rights reserved.
//

#import "GeneralButton.h"

@implementation GeneralButton

-(instancetype)initWithFrame:(CGRect)frame title:(NSString *)title tag:(int)tag color:(UIColor*)color
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.tag = tag;
        [self setTitleColor:color forState:UIControlStateNormal];
        [self setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
        [self setTitle:title forState:UIControlStateNormal];
        self.titleLabel.font = [UIFont systemFontOfSize:13];
        self.titleLabel.backgroundColor = [UIColor clearColor];
        
        [self setBackgroundImage:[UIImage imageNamed:@"product_details_btn"] forState:UIControlStateHighlighted];
        [self setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        
        [self.layer setMasksToBounds:YES];
        [self.layer setCornerRadius:5.0];
        [self.layer setBorderWidth:0.5];
        self.layer.borderColor = color.CGColor;
        
        [self addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        
        
    }
    return self;
    
}


-(void)btnClick:(UIButton *)btn{
    
    if (_delegate && [_delegate respondsToSelector:@selector(generalButtonOnClick:)]) {
        
        [_delegate generalButtonOnClick:btn];
        
    }
    
}

@end
